﻿<EditDataFormTemplateSpec 
	xmlns="bb_appfx_editdataformtemplate"
	xmlns:c="bb_appfx_commontypes" 
	ID="1958fa31-979c-4254-8d04-18a8609d9479" 
	Name="StewardshipPlan Edit Data Form"
	Description="REPLACE_WITH_DESCRIPTION" 
	Author="Blackbaud Professional Services"
	DataFormInstanceID="984a3e93-078f-4eba-8698-96f40952e1d6" 
	RecordType="Stewardship Plan"
	c:SecurityUIFolder="TDSM"
	>

	<SPDataForm>
		<LoadImplementation SPName="USP_DATAFORMTEMPLATE_EDITLOAD_STEWARDSHIPPLAN_EXTENSION">
			<c:CreateProcedureSQL>
				<![CDATA[
create procedure dbo.USP_DATAFORMTEMPLATE_EDITLOAD_STEWARDSHIPPLAN_EXTENSION
(
  @ID uniqueidentifier
 ,@DATALOADED bit = 0 output
 ,@TSLONG bigint = 0 output
 ,@DESIGNATIONID uniqueidentifier = null output
)
as
  set nocount on;
  set @DATALOADED = 1;
  set @TSLONG = 0;
  
  select
    @TSLONG = TSLONG
   ,@DESIGNATIONID = DESIGNATIONID
  from dbo.USR_STEWARDSHIPPLAN
  where ID = @ID;
  
  return 0;
]]>
			</c:CreateProcedureSQL>
		</LoadImplementation>

		<SaveImplementation SPName="USP_DATAFORMTEMPLATE_EDIT_STEWARDSHIPPLAN_EXTENSION">
			<c:CreateProcedureSQL>
				<![CDATA[
create procedure dbo.USP_DATAFORMTEMPLATE_EDIT_STEWARDSHIPPLAN_EXTENSION
(
  @ID uniqueidentifier
 ,@CHANGEAGENTID uniqueidentifier = null
 ,@DESIGNATIONID uniqueidentifier
)
as
set nocount on;
if @CHANGEAGENTID is null begin
  exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output;
end;
declare @CURRENTDATE datetime = getdate();

begin try
  if exists(select * from USR_STEWARDSHIPPLAN where id = @id) begin
    update dbo.USR_STEWARDSHIPPLAN
    set
      DESIGNATIONID = @DESIGNATIONID
     ,CHANGEDBYID = @CHANGEAGENTID
     ,DATECHANGED = @CURRENTDATE
    where ID = @ID;
  end
  else begin
    exec dbo.USP_DATAFORMTEMPLATE_ADD_STEWARDSHIPPLAN_EXTENSION @id,@id,@changeagentid,@designationid
  end;
end try
begin catch
  exec dbo.USP_RAISE_ERROR;
  return 1;
end catch

return 0;
]]>
			</c:CreateProcedureSQL>
		</SaveImplementation>

	</SPDataForm>

	<c:FormMetaData FixedDialog="true">
		<c:FormFields>
            <c:FormField FieldID="DESIGNATIONID" DataType="Guid" Caption="Designation" CaptionResourceKey="$$designation">
                <c:SearchList SearchListID="3187706b-b1ee-410f-b599-27aee1b26237" EnableQuickFind="true" />
            </c:FormField>
        </c:FormFields>
	</c:FormMetaData>
    
    <c:DataFormExtension DataFormInstanceID="7912e49c-349e-4d1c-bca7-5c173b785004" RenderStyle="AfterParent" TabCaption="Designation"/>
    
</EditDataFormTemplateSpec>